package com.api.gbhg.luoao.flow;

import com.api.gbhg.liwenjun.GBHGConstant;
import com.api.gbhg.liwenjun.VersionFlowUtil;
import com.api.gbhg.luoao.tool.ToolCURD;
import weaver.conn.RecordSet;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;

import java.util.HashMap;
import java.util.Map;
/**
 * 事业单位在职人员工资津贴补贴经费版本表同步
 *
 */
public class CauseWageAllowance implements Action {


    @Override
    public String execute(RequestInfo requestInfo) {
        //查询明细表
        RecordSet recordSet = ToolCURD.selectDetailnanlist(requestInfo, 1);
        double yszje = 0;
        while (recordSet.next()){
            String hjwy =  recordSet.getString("hjwy");

            if(!hjwy.isEmpty()){
                yszje = Double.parseDouble(hjwy)+yszje;
                if (yszje<0){
                    yszje=0;
                }
            }

        }
        Map<String,String> stringStringMap = new HashMap<>();
        stringStringMap.put("xmmin","xmmc");
        boolean b = VersionFlowUtil.sysDataToVersion(requestInfo.getRequestid(), requestInfo.getWorkflowid(),
                GBHGConstant.FlowVersionTableEnum.uf_sydwzzrygzjtbtjfbbb, stringStringMap);
        //把预算总金额插入到主表中
        boolean up = ToolCURD.updateVersionQuery( yszje, requestInfo.getRequestid());
        if (b){
            return SUCCESS;
        }else {
            requestInfo.getRequestManager().setMessagecontent("数据同步失败!");
            requestInfo.getRequestManager().setMessageid("7763");
            return FAILURE_AND_CONTINUE;
        }
    }
}
